<?php
class Statistic
{
    public static function add($object,$value)
    {
        $available = array('requests_30','register_30','friendvisit_30');
        $value = (int)$value;
        $time = floor(time()/1800)*1800;
        if(in_array($object, $available))
        {
            $query = 'INSERT INTO `stat__online` SET `time`='.$time.',`'.$object.'`=`'.$object.'`+'.$value.'
ON DUPLICATE KEY UPDATE `'.$object.'`=`'.$object.'`+'.$value;
            _database::query($query);
        }

       
    }

    public static function set_active_user()
     {
          if(rpc::$user_id)
        {
            $time = floor(time()/1800)*1800;
            $query = 'INSERT INTO `stat__online_onlineusers` SET `user_id`='.rpc::$user_id.',`time`='.$time.'
ON DUPLICATE KEY UPDATE `user_id`='.rpc::$user_id.',`time`='.$time;
            _database::query($query);
        }
     }

    public static function set($object,$value,$time = false)
    {
        $available = array('requests_30','register_30','friendvisit_30','online_30');
        $value = (int)$value;
        if(!$time)
        $time = floor(time()/1800)*1800;
        if(in_array($object, $available))
        {
            $query = 'INSERT INTO `stat__online` SET `time`='.$time.',`'.$object.'`='.$value.'
ON DUPLICATE KEY UPDATE `'.$object.'`='.$value;
            _database::query($query);
        }
    }
}
?>
